﻿
        //revise修补动作系列
        var ObjectsReviseBtn;
        function reviseRender() {
            $("#shopEditBtn").show();
            var revises = $("#shopPanle [revise='true']");
            //加入常住内存
            ObjectsReviseBtn = (revises.after("<span class='reviseBtn'></span>")).next();
            var _reviseBtn = revises.next();
            _reviseBtn.addClass("reviseLabel");

            _reviseBtn.click(function (evt) {
                if ($(this).prev().attr("revise") == "true") {

                    reviseClick(evt);
                }

            })
            //reviseSales
            $it = $("#shopSales");
            if ($it.get(0)) {
                var _addbtn = "<div class='revisePlus newSale'><input type='text' id='newSaleInput'><button class='btn-small' onclick='addSale()' >增加</button></div>";
                var _delbtn = "<button class='delBtn' title='删除' name='del'></button>";
                //var _editbtn = "<button class='editBtn' title='修改' name='edit'></button>";
                var _ablebtn = "<button class=' ableBtn' title='失效' name='able'></button>";

                $it.attr("reviseInit", 'true');
                $it.find(".sale").append("<div class='btn revisePlus'>" + _delbtn + _ablebtn + "</div>");
                $it.find("div:first").append(_addbtn);
                //ObjectsReviseBtn.push()
                $it.click(actionSale);
            }

        }

        function reviseClick(evt) {
            var it = evt.srcElement.previousSibling;


            switch(it.id){
                case "shopSize":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopSize", function (str) {
                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start")

                        reviseForSelect($("#shopSize"), eval(tranAjaxCallBackJson(str)));
                    });
                    break;
                case "shopHead":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopHead", function (str) {
                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start")
                        reviseForSelect($("#shopHead"), eval(tranAjaxCallBackJson(str)));
                    });
                    break;
                case "shopFoodStyle":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopClass", function (str) {

                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start");
                        reviseForCheckbox($("#shopFoodStyle"), eval(tranAjaxCallBackJson(str)));
                    });
                    break;
                case "shopEnvironment":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopEnvironment", function (str) {

                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start");
                        reviseForSelect($("#shopEnvironment"), eval(tranAjaxCallBackJson(str)));
                    });
                    break;
                case "shopClassMore":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopClass", function (str) {

                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start");
                        reviseForCheckbox($("#shopClassMore"), eval(tranAjaxCallBackJson(str)));
                    });
                    break;
                case "shopFit":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopFit", function (str) {

                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start");
                        reviseForCheckbox($("#shopFit"), eval(tranAjaxCallBackJson(str)));
                    });
                    break;
                case "shopTags":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopTags_default",function(str){
                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start");
                        reviseForTags($("#shopTags"), eval(tranAjaxCallBackJson(str)));

                    });
                    break;
                case "shopUtilityTags":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopUtilityTag", function (str) {

                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start");
                        reviseForCheckbox($("#shopUtilityTags"), eval(tranAjaxCallBackJson(str)),"img");
                    });
                    break;

                case "shopIntro":
                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start");
                        reviseForTextArea($(it));
                    break;

                case "shopPay":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopPay", function (str) {

                        reviseMaskRender("hide");
                        $(it).attr("revise", "start");
                        reviseForCheckbox($("#shopPay"), eval(tranAjaxCallBackJson(str)));
                    });
                    break;

                case "shopAlly":
                    reviseMaskRender("show", it);
                    $.get("/dict/getValueByName?name=shopAlly", function (str) {

                        reviseMaskRender("hide");
                        //$(it).attr("revise", "start");
                        reviseForCheckbox($("#shopAlly"), eval(tranAjaxCallBackJson(str)));
                    });
                    break;

                case "shopMemberAble":
                    //reviseMaskRender("show", it);

                    reviseForAble($("#shopMemberAble"));

                    break;

                /**********来至菜肴的补完动作****************/
                case "foodIntro":
                    reviseMaskRender("hide");
                    //$(it).attr("revise", "start");
                    reviseForTextArea($(it));
                    break;
                /**********来至菜肴的补完动作****************/  

                default:
                    reviseMaskRender("hide");
                    //$(it).attr("revise", "start")
                    reviseForInput($(it));
            }


        };
        //sale add ajax提交
        function addSale() {
            var _newSaleValue = $("#newSaleInput").val().trim();
            if (strCheck(_newSaleValue, '')) { sysAlert(1000) }
            $.get("/shop/addSale/" + getShopId(), { content: _newSaleValue }, function (str) {
                str = eval(str);
                if (str.result == 'ok') {
                    var _delbtn = "<button class='delBtn' title='删除' name='del'></button>";
                    //var _editbtn = "<button class='editBtn' title='修改' name='edit'></button>";
                    var _ablebtn = "<button class=' ableBtn' title='失效' name='able'></button>";

                    var user = getLoginUser();
                    var _newSaleValue = $("#newSaleInput").val().trim();
                    $("#shopSales div:first").after('<div class="sale" title="' + user.ame + '" id="' + str.content + '"><span class="datetime">' + new Date().pattern("yyyy-MM-dd") + '</span>' + _newSaleValue + '<div class="btn revisePlus">' + _delbtn + _ablebtn + '</div></div>')
                }
            });
        }
        //sale 事件处理
        function actionSale(evt) {
            var target = evt.target;
            switch (target.getAttribute("name")) {
                case "del":
                    if (!sysConfirm()) {return}
                    $.get("/shop/delSale/" + getShopId(), { saleId: target.parentNode.parentNode.id }, function (str) {
                        str = eval(str);
                        if (str.result == 'ok') {
                            $("#" + str.content).remove()
                        }
                    });
                    break;
                case "able":
                    $.get("/shop/ableSale/" + getShopId(), { saleId: target.parentNode.parentNode.id }, function (str) {
                        str = eval(str);
                        if (str.result == 'ok') {
                            $("#" + str.content).remove()
                        }
                    });
                    break;
            };
        
        }
        function reviseMaskRender(type, it) {
            it = $(it);
            if ($("#reviseMaskPanle").length==0) {
                $(document.body).append("<div id='reviseMaskPanle'></div>");

            }
            var reviseMaskDom = $("#reviseMaskPanle");
            if (type == "hide") { reviseMaskDom.css("display", "none"); return }

            elLocation(reviseMaskDom, it, 0); //定位
            reviseMaskDom.width(it.outerWidth());
            reviseMaskDom.height(it.outerHeight());
            reviseMaskDom.css("opacity", 0.3);
            reviseMaskDom.css("display", "block");


        }
        function reviseForTags($obj,json){
            var str = "<div id='"+$obj.attr("id") + "revise' class='shopTagsRevisePanle reviseForm'>";
            str +="<input name='shopTags' class='shopTagsRevise' value='"+$obj.html().replace(/<\/A><A>/g,",").replace("<A>","").replace("</A>","")+"' id='inputTags'/><div id='shopTagsTemp'>";
            for (var im in json){
                str += "<a class='shopTag' href='###' onclick=selectTagsAPP_act(this,'inputTags')>" + json[im].Key + "</a>";         
            }
            str += "</div>"
            str +="</div><div class='reviseSaveBtn' onclick=reviseSubmit('"+$obj.attr("id")+"',this.previousSibling.children(0).value,'tags')></div>"
            reviseFloat($obj, str);
            
        }
        function reviseForAble($obj) {
            var _type = $obj.attr("inputType").split(",")
            var _value = $obj.html();
            var str = "<div id='" + $obj.attr("id") + "revise' class='reviseForm' >";

            str += "<input name='" + $obj.attr("id") + "' type='radio' value='true' ";
            if(_type[0]==_value){str+="checked='check'"}
            str +="/>" + _type[0];
            str += "<input name='" + $obj.attr("id") + "' type='radio' value='false' ";
            if (_type[1] == _value) { str += "checked='check'" }
            str += "/>" + _type[1];
            str += "<input name='" + $obj.attr("id") + "' type='radio' value='null' ";
            if (_type[2] == _value) { str += "checked='check'" }
            str += "/>" + _type[2];

            str += "</div><div class='reviseSaveBtn' onclick=reviseSubmit('" + $obj.attr("id") + "',this.previousSibling.children(0).value,'checkbox')></div>";
            reviseFloat($obj, str);
        }
        function reviseForInput($obj) {

            var str = "<div id='" + $obj.attr("id") + "revise' class='reviseForm' >";
            str +="<input name='"+$obj.attr("id")+"' class='' value='" + $obj.attr("inputValue") + "'/>";
            str += "</div><div class='reviseSaveBtn' onclick=reviseSubmit('"+$obj.attr("id")+"',this.previousSibling.children(0).value)></div>";
            reviseFloat($obj,str);
        }
        function reviseForTextArea($obj){
            var str = "<div id='" + $obj.attr("id") + "revise' class='reviseForm' >";
            str +="<textarea name='"+$obj.attr("id")+"' class='shopIntroInput' size='8' >"+$obj.attr("inputValue")+"</textarea>";
            str += "</div><div class='reviseSaveBtn' onclick=reviseSubmit('"+$obj.attr("id")+"',this.previousSibling.children(0).value,'textArea')></div>";
            reviseFloat($obj,str);        
        }

        function reviseForSelect($obj,json) {
            var str = "<div id='" + $obj.attr("id") + "revise' class='reviseForm' >";
            str += "<select name='"+$obj.attr("id")+"'>"
            var inputValue = $obj.attr("inputValue");
            for (var im in json) {

                str += "<option value='" + json[im].Key+"'"
                if (json[im].Key.toString() == inputValue) {
                    str += " selected='true'";
                }
                str += ">" + json[im].Value + "</option>";
            }
            str += "</select></div><div class='reviseSaveBtn' onclick=reviseSubmit('" + $obj.attr("id") + "',this.previousSibling.children(0).value,'select')></div>";

            reviseFloat($obj,str);

        }
        function reviseForCheckbox($obj, json, type) {
            if (type == undefined || type == null) { type = "checkbox" }
            var str = "<div id='" + $obj.attr("id") + "revise' class='reviseCheckBox reviseForm' style='min-width:200px;max-width:400px;width:300px'>";
            
            var inputValue = $obj.attr("inputValue");
            var _arr = inputValue.split(',');

            for (var im in json) {

                str += "<input name='"+$obj.attr("id")+"' type='checkbox' value='" + json[im].Key + "'";

                if (arrstrContrastItem(_arr, json[im].Key)) {

                    str += " checked='checked'";
                }
                str += "/>" + json[im].Value + "";
            }
            str += "<div class='reviseSaveBtn' onclick=reviseSubmit('" + $obj.attr("id") + "',getChecked('" + $obj.attr("id") + "').value,'" + type + "')></div></div>";
            reviseFloat($obj,str);
        }
        function reviseForRaido($obj, json) {

            var str = "<div id='" + $obj.attr("id") + "revise' class='reviseCheckBox reviseForm' style='min-width:200px;max-width:400px;width:300px'>";

            var inputValue = $obj.attr("inputValue");
            var _arr = inputValue.split(',');

            for (var im in json) {

                str += "<input name='" + $obj.attr("id") + "' type='radio' value='" + json[im].Key + "'";

                if (arrstrContrastItem(_arr, json[im].Key)) {

                    str += " checked='checked'";
                }
                str += "/>" + json[im].Value + "";
            }
            str += "</div><div class='reviseSaveBtn' onclick=reviseSubmit('" + $obj.attr("id") + "',getChecked('" + $obj.attr("id") + "').value,'checkbox')></div>";
            reviseFloat($obj, str);
        }
        function getChecked(name){
            var checkArr = document.getElementsByName(name)
            var s = new Array()
            var v = new Array()
            for(var i=0;i<checkArr.length;i++) {
                if(checkArr[i].checked) {
                    s[s.length]= checkArr[i].nextSibling.nodeValue;
                    v[v.length]= checkArr[i].value;

                }    
            }
            return {text:s.join(','),value:v.join(',')};
        }

        function reviseSubmit(_name, _value, type) {
            var _url, arguments;
            if (_name.indexOf("food")==0) {
                _url = "/food/Ajax_revise"
                arguments = { id: getPageFoodId(), name: _name, value: _value }
            } else {
                _url = "/shop/Ajax_revise"
                arguments = { id: getPageShopId(), name: _name, value: _value }

            }
            $.post(_url, arguments, function (str) {
                var json = eval(str);
                if (json.result == "ok") {
                    //提示
                    var reviseFloatPanle = $("#reviseFloatPanle");
                    var text, name;
                    _obj = reviseFloatPanle.get(0).children(0).children(0);
                    name = _obj.name;
                    obj = $("#" + name)
                    var _offset = obj.offset();
                    actionTips.show("修改成功!", _offset.left, _offset.top);

                    reviseUpdate(type);
                    //隐藏
                    hideReviseFloat()
                    

                } else {
                    sysAlert(1001);
                }
            });
            
        
        }
        //更新目标值
        function reviseUpdate(type){
            var reviseFloatPanle = $("#reviseFloatPanle");
            var text,name,inputValue;
            _obj = reviseFloatPanle.get(0).children(0).children(0);
            name = _obj.name;
            obj = $("#"+name)
            switch(type){
                case "checkbox":
                    var _c = getChecked(name);

                    text = _c.text;
                    inputValue = _c.value;
                    break;
                case "select":
                    text = _obj.options[_obj.selectedIndex].text;
                    inputValue = _obj.options[_obj.selectedIndex].value;
                    break;
                case "tags":

                    inputValue = "<A>" + _obj.value.replace(/\,/g, "</A><A>") + "</A>";
                    text = inputValue;

                    break;
                case "img":
                    var _c = getChecked(name);
                    var _ccc = _c.text.split(",");
                    var _vvv = _c.value.split(",")
                    inputValue = "";
                    for (var i = 0; i < _ccc.length; i++) {
                        inputValue += "<img src='"+baseConfig.siteThemePath+"images/UtilityTag0" + _vvv[i] + ".jpg' title='" + _ccc[i] + "'/>";
                    }
                    text = inputValue

                    inputValue = _c.value;
                    break;
                default:
                    text = _obj.value;
                    inputValue = text;
                    break;
            }
            //alert(text)
            obj.html(text);
            obj.attr("inputValue",inputValue);
            reviseFloatPanle.empty();
            reviseFloatPanle.css("display","none")
            obj.attr("revise", "true");
        
        }

        function reviseFloat($obj,html){
            if($("#reviseFloatPanle").length==0){
                $(document.body).append("<div id='reviseFloatPanle'></div>");
            }
            var $reviseFloatPanle = $("#reviseFloatPanle");

            $reviseFloatPanle.html(html);
            //定义大小。坐标
            elLocation($reviseFloatPanle, $obj, 0, -6, -5);
            //显示Mask
            floatPanle.showMark(hideReviseFloat);
            $reviseFloatPanle.show();

        }
        function hideReviseFloat() {
            floatPanle.hideMark();
            var $reviseFloatPanle = $("#reviseFloatPanle");
            $reviseFloatPanle.hide();
        }
//***shop***出初化/
    function initComment() {
        $("#addCommentBtn").click(function () {
            
            var poatData = $("#comment").serializeArray();
            $.post("/Comment/add/" + getPageShopId(), poatData, function (str) {

                alert(str)
            });
        })
        /*
        $("#getCommentBtn").click(function () {
            $.get("/Comment/get/"+getPageShopId(),function(text){
                alert(text.toString())
            });
        })
        */

    }
    //得到评论start:开始数,end:结束数
    function getComments(start, end) {
            if (start == undefined) { start = 0 }
            if (end == undefined) { end=5}
            $.get("/Comment/get/" + getPageShopId()+"?start="+start+"&end="+end, parseCommentJSON);       
        }
        function parseCommentJSON(){
 
            var json = arguments[0]

            for(var i=0;i<json.length;i++){
                
                writeCommentJSON(json[i])
            }
                
        }
        function writeCommentJSON(json){

            
            var newCommentNode = $("#commentTemp").clone(true);
            newCommentNode.attr("id",json["Id"]);
            var ns = newCommentNode.find("._var");

            ns.each(function () {
                var str = $(this).text();
                str = str.substring(1, str.length);
                var _val = eval("json" + str);


                if (str == '["userId"]') {
                    _val = nnUserSet(_val);
                    
                 }

                if (_val != null && _val != "") {
                    $(this).get(0).innerHTML = _val;
                } else {
                    $(this).parent().hide();

                }

                if ($(this).get(0).className == "date _var") {

                    $(this).get(0).innerHTML = JsonDateToDate($(this).get(0).innerHTML, "yyyy-MM-dd");

                }
                if ($(this).get(0).className == "time _var") {
                    $(this).get(0).innerHTML = JsonDateToDate($(this).get(0).innerHTML,"hh:mm");

                }
            })
            $("#commentsBar").append(newCommentNode);
        }
        //菜添加-修改
        function addItem(){
            var formdata = $("#xxxx").serializeArray();

            $.post("/shop/Ajax_additem/"+getPageShopId(),formdata,function(json){alert(json)})            
        }

        //显示impressionForm
        function showImpressionForm(){
            elLocation($("#impressionForm"),$("#impressionBtn"),0,26,0);
            $("#impressionForm").show();

            $("#impressionBtn").addClass("selected");

        }
        function hideImpressionForm(){
            $("#impressionBtn").removeClass("selected");
            $("#impressionForm").hide();

        }
        //印象记录添加
        function addImpression(){
            var _iwEl =  $("#impressionWord");
            var iw = _iwEl.val();
            if(iw==""){return}
            var formdata = $("#impressionForm").serializeArray();
            $.post("/impression/add/",formdata,function(json){
                writeImpressionJSON(json)
                _iwEl.val("");
                hideImpressionForm();
            })

        }
        function getImpressions(start,end) {

            if (start == undefined) { start = 0 }
            if (end == undefined) { end = 8 }
            $.get("/impression/get/" + getPageShopId() + "?start=" + start + "&end=" + end, parseImpressionJSON);
            
        }
        function getImpressionById(){
            
            //$.get("/ajax/impression/getById/"+getPageShopId(),parseImpressionJSON);
            
        }
        function parseImpressionJSON(){
            var json = arguments[0]

            for(var i=0;i<json.length;i++){
                
                writeImpressionJSON(json[i])
            }            
        }
        function writeImpressionJSON(json){


            var newImpression = $("#impressionTemp").clone(true);
            newImpression.attr("id", json["Id"]);
            var ns = newImpression.find("._var");

            ns.each(function () {
                var str = $(this).text();
                var _el = $(this).get(0);
                _el.constructor
                str = str.substring(1, str.length);

                var _val = eval("json" + str);
                if (str == '["userId"]') { _val = userName; _el.attr("href", json["userId"]); }


                _el.innerHTML = _val;

                if (_el.className == "datetime _var") { $(this).next().next().attr('title', JsonDateToDate(_el.innerHTML)); $(this).hide(); };
            })

            $("#shopImpressionsBar").append(newImpression)            
        }

        //ajax印象记录删除:shopId,ImpressionWord 
        function delImpressionAjax(Id,content,itemObj){

            $.get("/impression/delByShopIdByContent/"+Id,{word:content},function(result){removeImpressionTag(result,itemObj)});
            
        
        }
        function removeImpressionTag(result,itemObj){
                if(result == "true"){
                    itemObj.remove()
                }
        }
        //解析shop.item的json集成
        function parseShopItemJson(jsonstr){
            if (!jsonstr) { jsonstr = $("#shopItemJsonStr").html() };
            if (jsonstr.trim() == "") {return;}
            var json = eval(jsonstr);


            var html=""
            for(var i=0;i<json.length;i++){
                html += "<div class='item'><a href='"+json[i].id+"' title='更新时间"+json[i].date+"'><span class='name'>"+json[i].name+"</span></a><span class='count'>"+json[i].count+"</span></div>"
            }

            $("#shopItemsBar").append(html);
        }
        function  getPageShopId(){
            return $("#shopPanle").attr("shopId")
        }
        function getPageFoodId() {
            return $("#foodPanel").attr("foodId")
        }
        //impression处理事件
        function impressionEvent(evt){
            evt = $.event.fix(evt)
            var el = $(evt.target);
            var item = el.parent().parent(".impression");
            var impressionId = item.attr("id");
            var content = item.find(".content").text()
            var action = el.attr("class")
            
            //ajax del 该店的此印象字记录
            if(action == "delBtn"){

                var shopId = getPageShopId();
                delImpressionAjax(impressionId, content,item)

            }


        }

        //允许编辑按键******************************************
        function abledEdit(el) {
            var str;
            if (el.getAttribute("edit") == "true") {
                str = "hidden";
                el.setAttribute("edit", "false");
                el.className = "ableEditBtn"
                el.innerHTML = "编辑";

                if (typeof(showMapEdit)!="undefined") {
                    hideMapEdit();
                }
                //精确统计按钮
                $("#resetStatistics").hide();

            } else {
                str = "visible";
                el.setAttribute("edit", "true");
                el.className = "disabledEditBtn"
                el.innerHTML = "取消编辑";

                if (typeof(showMapEdit)!="undefined") {
                    showMapEdit();
                }
               $("#resetStatistics").show();
            }
            el.disabled = true;

            /*由于增加了shopSales 动态增加reviseBtn，原Objectsrevise内存对象只存了页面出始化的元素。因此变的不全了*/
            ObjectsReviseBtn.each(function() {

                $(this).css("visibility", str);
            })

            //修改增加对revisePlus的判断
            $("div .revisePlus").css("visibility", str)
            el.disabled = false;


        }


        //浏览更多图片
        var shopPics = new Array();
        function showMoreShopPic() {

            var $contentPanle = $('#contentPanle');
            var $picsPanle = $('#picsPanle')
            if (!$picsPanle.is(":hidden")) {
                $picsPanle.hide();
                $contentPanle.show();
                return;      
            }
            $picsPanle.show()
            $contentPanle.hide()

            if ($picsPanle.html().length>2) {return }
            $picsPanle.height($contentPanle.height());
            shopPics = $picsPanle.attr('content').replace(/></g,">||<").split("||");

            timerAddElement();
        }
        function timerAddElement() {

            var $picsPanle = $('#picsPanle');
            if (shopPics.length > 0) {
                //alert(shopPics.pop())

                $picsPanle.append(shopPics.pop())
            } else { return }
            setTimeout(timerAddElement, 100);
        }
        function getShopId() {
            return document.getElementById("shopPanle").getAttribute("shopId");
        }
        function changeShopMenu(it) {
            /*无刷新时的脚本-----遗弃
            var _lis = it.parentNode.children;
            for (var i = 0; i < _lis.length; i++) {
                var _dom = document.getElementById(_lis[i].getAttribute("target"))
                //alert(_dom.id)
                if (it == _lis[i]) {

                    if (_dom) {
                        _dom.style.display = "block";
                        var _cp = document.getElementById("contentPanle");
                        _cp.style.display = "block";
                        _dom.style.height = document.getElementById("contentPanle").scrollHeight + "px";
                        if (_dom != _cp) { _cp.style.display = "none" };
                        it.className = "openMorePicBtnCls";
                    }

                } else {
                    if (_dom) {

                        _dom.style.display = "none";

                        _lis[i].className = "closeMorePicBtnCls";
                   }
                }
            }
            无刷新时的脚本-----遗弃*/

            //for 刷新页面channel显示 适用SEO
            it.className = "openMorePicBtnCls";
        }



        /*tag*/
        function selectTagsAPP(id, tagId, fromId) {
            var untagBox = document.getElementById(id);
            var tagBox = document.getElementById(tagId);
            tagBox.setAttribute("target", id)
            str = untagBox.innerHTML
            untagBox.setAttribute("target", tagId)
            var tags = str.split(",")
            var html = new Array();
            for (var i = 0; i < tags.length; i++) {
                html[i] = "<a class='shopTag' href='###' onclick='selectTagsAPP_act(this)'>";
                html[i] += tags[i];
                html[i] += "</a>";
            }
            untagBox.innerHTML = html.join("");
        }
        function selectTagsAPP_act(it,id) {

            //document.getElementById(it.parentNode.getAttribute("target")).appendChild(it)
            //it.parentNode.getAttribute("target")

            addTags(it.innerText, id);


        }
        function addTags(str, id) {

            if (!vTag(str)) { alert("err"); return }
            var tagBox = document.getElementById(id)

            var tags = tagBox.value.split(",");
            if (tags[0] == "") { tags.shift() }
            for (var i = 0; i < tags.length; i++) {
                if (tags[i] == str) { return }
            }

            tags.push(str)

            tagBox.value = tags.join(",")

        }
        function addNewTag(id, targetID) {

            var newTagInput = document.getElementById(id);

            addTags(newTagInput.value, targetID)
        }
        //tag有效验证
        function vTag(str) {
            if (str == "") { return false }
            if (str.indexOf(",") >= 0) { return false }
            return true;
        }

        //菜频道
        function getItemDetailImpression(evt,popup) {
            evt = $.event.fix(evt)
            var el = $(evt.target).get(0);
            if (!popup) {
                document.getElementById("detailFrame").src = "/food/detail/" + el.id;
                $("#shopItemList").hide();
                $("#detailFrame").show();
            } else {
                window.open("/item/detailImpress/" + el.id, "", "width=500,height=500");
            }
            /* ajax
            if (el.tagName.toLowerCase() == "li" && el.id) {
            $.get("/item/getDetail/" + el.id, { type: "json" }, function (result) {
            debugger;
            alert(result)
            });
            }
            */
        }
        //显示Item Detail面板。隐藏item List面板
        function showItemDetail() {
            $("#shopItemList").show();
            $("#detailFrame").hide();
        }
        //图片上传

        //显示食场图片上传层
        function showShopPicUpload() {
            bulidFlashUpload("/shop/Ajax_addPic",getShopId(),null);
            var xx = new actFloat(document.getElementById("shopPicUpload"), "picUloadFloatPanle", "picUploadFloat")
            xx.loc(300, null, 300, 300).show();
            return void (0);

        }
        //显示菜肴图片上传层(引用shop图片上传层，修改upload url)
        function showfoodPicUpload(id) {
            bulidFlashUpload("/food/Ajax_addPic",id,null);
            var xx = new actFloat(document.getElementById("shopPicUpload"), "picUloadFloatPanle", "picUploadFloat")
            xx.loc(300, null, 300, 300).show();
            return void (0);

        }
        function shopPicReplace() {
            var xx = new actFloat(document.getElementById("shopPicUpload"), "picUloadFloatPanle", "picUploadFloat");
            xx.loc(300, null, 300, 300).show();
        }
        /*图片操作*/

        function ActionProcessShopPic(evt) {
            evt = $.event.fix(evt)
            var el = $(evt.target);

            if (el.hasClass("replaceBtn")) {

                shopPicReplace();
                return;
            }
            if (el.hasClass("delBtn")) {
                if (window.confirm("是否")) {
                    delShopPic()
                }

            }
        }
        function delShopPic(id) {

            if (picsActFloat.$floatTarget.src == "")
                return;
            var _src = picsActFloat.$floatTarget.attr("src");
            var picUrl = _src.substring(_src.lastIndexOf("\\") + 1, _src.length - 4);

            $.post("/shop/Ajax_delPic/" + getShopId(), { picUrl: picUrl }, delShopPicCallBack);
        }
        function delShopPicCallBack(info) {

            info = eval(info)
            if (info.result == "ok") {

                picsActFloat.$floatTarget.remove();
                picsActFloat.hidden();

            } else {
                alert(info.content)
            }

        }
        function hideProcessShopPic(evt) {
            evt = $.event.fix(evt)
            var el = $(evt.target);
            if (el.hasClass("shopPicListItem") || el.hasClass("processShopPicFloatCls")) {

                return;
            }
            if (document.getElementById("processShopPicFloatPanle")) {
                document.getElementById("processShopPicFloatPanle").style.display = "none";
            }
        }
        //当前的actFloat(图片act处理层)
        var picsActFloat = new actFloat(document.getElementById("processShopPicPanle"), "processShopPicFloatPanle", "processShopPicFloatCls");
        function showProcessShopPic(evt) {

            evt = $.event.fix(evt)
            var el = $(evt.target);
            if (!el.hasClass("shopPicListItem")) {
                return;
            }
            //picsActFloat = new actFloat(document.getElementById("processShopPicPanle"), "processShopPicFloatPanle", "processShopPicFloatCls")
            var offset = el.offset()
            picsActFloat.$floatTarget = el;
            picsActFloat.loc(el.width(), el.height() / 2, offset.top + el.height()-29, offset.left).show();



        }

        /***flash上传***/

        //建立flash上传控制
        var flashUpload=null;  //全局图片上传对象变量
        function bulidFlashUpload(uploadUrl, id, session) {
            if (flashUpload == null) {
                flashUpload = new SWFUpload({
                    // Backend Settings
                    upload_url: uploadUrl,
                    flash_url: "/Content/Components/SWFUpload/swfupload_fp10/swfupload.swf",
                    flash9_url: "/Content/Components/SWFUpload/swfupload_fp9/swfupload_fp9.swf",

                    //                    post_params: {
                    //                        "ASPSESSID": session
                    //                    },

                    // File Upload Settings
                    http_success: [201, 202],
                    use_query_string: false,
                    requeue_on_error: false,

                    file_size_limit: "2 MB",
                    file_types: "*.jpg",
                    file_types_description: "Web Image Files",
                    file_upload_limit: "0",
                    file_queue_limit: 2,


                    file_queued_handler: fileQueued,
                    file_queue_error_handler: fileQueueError,
                    file_dialog_complete_handler: fileDialogComplete,
                    upload_start_handler: uploadStart,
                    upload_progress_handler: uploadProgress,
                    upload_error_handler: uploadError,
                    upload_success_handler: uploadSuccess,
                    upload_complete_handler: uploadComplete,
                    queue_complete_handler: queueComplete,



                    // Button settings
                    //button_image_url: "/Content/images/pictures.png",
                    button_placeholder_id: "uploadButton",

                    button_image_url: "/Content/images/tag2.png",
                    button_width: 61,
                    button_height: 22,
                    button_text: "<b>上传</b> ",
                    button_text_style: ".redText { color: #FF0000; }",
                    button_text_left_padding: 3,
                    button_text_top_padding: 2,
                    button_action: SWFUpload.BUTTON_ACTION.SELECT_FILES,
                    button_disabled: false,
                    button_cursor: SWFUpload.CURSOR.HAND,
                    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,

                    custom_settings: {
                        progressTarget: "fsUploadProgress",
                        cancelButtonId: "btnCancel"
                    },
                    post_params: { "Id": id },
                    // Debug Settings
                    debug: false
                });
            }
            //修改上传url
            /////////////////////////////////////////////////////////////////////////////////////////////////
            //他妈的，怎么动态修改uploadurl都是不行，原来可能来至movieElement.CallFunction不识别的原因，为什么我也不知道，他妈的。难到CallFunction在新版flashplayer去掉了？
            //lashUpload.setUploadURL(uploadUrl);
            //////////////////////////////////////////////////////////////////////////////////////////////////
            //flashUpload.setPostParams({ "Id": id });


        }
/**shop中food表单动作**/

        //提交
        function foodCommentFormSubmit() {
            var _fs = $("#foodCommentForm").find("[name='foodName']");
            for (var i = 0; i < _fs.length; i++) {
                if (_fs.eq(i).val().trim() != "") { $("#foodCommentForm").get(0).submit(); return }
            }
            alert("请录入一个菜肴的名称");
        }


        function addFoodCommentItem() {
            var o = $("#foodCommentFormContent");
            var c = o.children().eq(1).clone();


            c.find(".delBtn_s").removeClass("hidden");
            c.find("input").each(function () {
                $(this).val("");
            })
            o.append(c);
            //c.prev().find(".addBtn_s").addClass("hidden");
        }
        function delFoodCommentItem(it) {
            $(it).parent("li").remove();
        }
        //显示菜肴添加表单与隐藏

        function foodCommentFormPanle_toggle() {

            var _w = 650;
            var ffp = $('#foodCommentFormPanel');

            if (ffp.css("width") == _w + "px") {
                ffp.animate({ width: foodCommentFormPanle_toggle.org }, 300)

            } else {
                foodCommentFormPanle_toggle.org = ffp.css("width");
                ffp.animate({ width: _w }, 300)
            }
        }
        foodCommentFormPanle_toggle.org = 0;

